{extend name="/public/base" /}
{block name="header"}{/block}
{block name="menu"}{/block}

{block name="main"}
<article class="cl pd-20">
	<form action="{:url('module/create')}" method="post" class="form form-horizontal" id="form-module-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">
				<span class="c-red">*</span>模块名：
			</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="moduleName" name="module_name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">
				<span class="c-red">*</span>控制器：
			</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" autocomplete="off" value="" placeholder="控制器" name="controller">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">
				<span class="c-red">*</span>方法：
			</label>
			<div class="formControls col-xs-8 col-sm-9">
				<span class="select-box">
					<select class="select valid" name="action" aria-invalid="false">
						<option value="index">列表</option>
						<option value="create">新增</option>
						<option value="edit">修改</option>
						<option value="delete">删除</option>
					</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">
				<span class="c-red">*</span>是否作为菜单显示：
			</label>
			<div class="formControls col-xs-8 col-sm-9">
				<span class="select-box">
					<select class="select valid" name="is_menu" aria-invalid="false">
						<option value="0">否</option>
						<option value="1">是</option>
					</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">备注：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea name="description" cols="" rows="" class="textarea"  placeholder="说点什么...100个字符以内" dragonfly="true" onKeyUp="textarealength(this,100)"></textarea>
				<p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
{/block}

{block name="_footer"}
{js href="/static/backend/lib/jquery.validation/1.14.0/jquery.validate.js" /}
{js href="/static/backend/lib/jquery.validation/1.14.0/validate-methods.js" /}
{js href="/static/backend/lib/jquery.validation/1.14.0/messages_zh.js" /}
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-module-add").validate({
		rules:{
			module_name:{
				required:true,
				minlength:4,
				maxlength:16
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				type: 'post',
				url:"{:url('module/create')}",
				success: function(data){
					layer.alert(data.message,{icon:1,time:3000}, function () {
						var index = parent.layer.getFrameIndex(window.name);
						parent.location.reload();
						parent.layer.close(index);
					});
				}
			});

			return false;
		}
	});
});
</script>
{/block}